Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the AspnetPaths class.
	''' </summary>
	<Serializable> _
	Public Partial Class AspnetPathsCollection 
	Inherits ActiveList(Of AspnetPaths, AspnetPathsCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the aspnet_Paths table.
	''' </summary>
	<Serializable> _
	Public Partial Class AspnetPaths 
	Inherits ActiveRecord(Of AspnetPaths)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("aspnet_Paths", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarApplicationId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarApplicationId.ColumnName = "ApplicationId"
                colvarApplicationId.DataType = DbType.Guid
                colvarApplicationId.MaxLength = 0
                colvarApplicationId.AutoIncrement = false
                colvarApplicationId.IsNullable = false
                colvarApplicationId.IsPrimaryKey = false
                colvarApplicationId.IsForeignKey = true
                colvarApplicationId.IsReadOnly = false
                
                
				colvarApplicationId.ForeignKeyTableName = "aspnet_Applications"
                
                schema.Columns.Add(colvarApplicationId)
                
                Dim colvarPathId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarPathId.ColumnName = "PathId"
                colvarPathId.DataType = DbType.Guid
                colvarPathId.MaxLength = 0
                colvarPathId.AutoIncrement = false
                colvarPathId.IsNullable = false
                colvarPathId.IsPrimaryKey = true
                colvarPathId.IsForeignKey = false
                colvarPathId.IsReadOnly = false
                
						colvarPathId.DefaultSetting = "(newid())"
				
                
                schema.Columns.Add(colvarPathId)
                
                Dim colvarPath As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarPath.ColumnName = "Path"
                colvarPath.DataType = DbType.String
                colvarPath.MaxLength = 256
                colvarPath.AutoIncrement = false
                colvarPath.IsNullable = false
                colvarPath.IsPrimaryKey = false
                colvarPath.IsForeignKey = false
                colvarPath.IsReadOnly = false
                
                
                schema.Columns.Add(colvarPath)
                
                Dim colvarLoweredPath As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarLoweredPath.ColumnName = "LoweredPath"
                colvarLoweredPath.DataType = DbType.String
                colvarLoweredPath.MaxLength = 256
                colvarLoweredPath.AutoIncrement = false
                colvarLoweredPath.IsNullable = false
                colvarLoweredPath.IsPrimaryKey = false
                colvarLoweredPath.IsForeignKey = false
                colvarLoweredPath.IsReadOnly = false
                
                
                schema.Columns.Add(colvarLoweredPath)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("aspnet_Paths",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("ApplicationId")> _
        Public Property ApplicationId As Guid 
			Get
				Return GetColumnValue(Of Guid)("ApplicationId")
			End Get
		    
			Set
				SetColumnValue("ApplicationId", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("PathId")> _
        Public Property PathId As Guid 
			Get
				Return GetColumnValue(Of Guid)("PathId")
			End Get
		    
			Set
				SetColumnValue("PathId", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Path")> _
        Public Property Path As String 
			Get
				Return GetColumnValue(Of String)("Path")
			End Get
		    
			Set
				SetColumnValue("Path", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("LoweredPath")> _
        Public Property LoweredPath As String 
			Get
				Return GetColumnValue(Of String)("LoweredPath")
			End Get
		    
			Set
				SetColumnValue("LoweredPath", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
	    #Region "PrimaryKey Methods"
	    
			Public Function AspnetPersonalizationAllUsersRecords() As Data.AspnetPersonalizationAllUsersCollection 
	
				Return New Data.AspnetPersonalizationAllUsersCollection().Where(AspnetPersonalizationAllUsers.Columns.PathId, PathId).Load()
	
			End Function
			
			Public Function AspnetPersonalizationPerUserRecords() As Data.AspnetPersonalizationPerUserCollection 
	
				Return New Data.AspnetPersonalizationPerUserCollection().Where(AspnetPersonalizationPerUser.Columns.PathId, PathId).Load()
	
			End Function
			
		#End Region
		
		
		
		
		
		
	    
	    #Region "ForeignKey Methods"
	    
		''' <summary>
		''' Returns a AspnetApplications ActiveRecord object related to this AspnetPaths
		''' </summary>
		Public Property AspnetApplications() As Data.AspnetApplications
			Get
				Return Data.AspnetApplications.FetchByID(Me.ApplicationId)
			End Get
			Set
				SetColumnValue("ApplicationId", Value.ApplicationId)
			End Set
		End Property
	    
	    #End Region
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varApplicationId As Guid,ByVal varPathId As Guid,ByVal varPath As String,ByVal varLoweredPath As String)
			Dim item As AspnetPaths = New AspnetPaths()
			
            item.ApplicationId = varApplicationId
            
            item.PathId = varPathId
            
            item.Path = varPath
            
            item.LoweredPath = varLoweredPath
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varApplicationId As Guid,ByVal varPathId As Guid,ByVal varPath As String,ByVal varLoweredPath As String)
			Dim item As AspnetPaths = New AspnetPaths()
		    
                item.ApplicationId = varApplicationId
				
                item.PathId = varPathId
				
                item.Path = varPath
				
                item.LoweredPath = varLoweredPath
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared ApplicationId As String = "ApplicationId"
            
            Public Shared PathId As String = "PathId"
            
            Public Shared Path As String = "Path"
            
            Public Shared LoweredPath As String = "LoweredPath"
            
		End Structure
		#End Region
	End Class
End Namespace
